package work;

import java.math.BigDecimal;
import java.util.Scanner;

public class Fruit {
    final static String regex = " ";

    final static String zero = "0";

    final static String biaozhun = "您所购买商品的总价为：";

    final static String caomei = "草莓限时打 8 折，";

    final static String caomeisum = "0.8";

    final static String onehundred = "100";

    final static int ten = 10;

    /**
     * 判断符串是否为空
     * @param s 输入的字符串
     * @return 返回是否
     */
    public static boolean isBlank(String s){
        return s == null || s.isEmpty();
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String type = sc.nextLine();
        String number = sc.nextLine();
        Integer num = Integer.parseInt(type);
        String ret = zero;
        if(isBlank(number)){
            ret = "输入的水果各类数量为空！";
        }else if (num == null || num < 1 || num > 4){
            ret = "输入的计算形式不对！";
        }else {
            if (num == 1){
                ret = one(number);
            }else if (num == 2){
                ret = two(number);
            }else if (num == 3){
                ret = three(number);
            }else if (num == 4){
                ret = four(number);
            }
        }
        System.out.println(ret);
    }

    /**
     * 输入题目1
     * @param number 水果行
     * @return 回复语句
     */
    public static String one(String number){
        String[] cou = number.split(regex);
        int length = cou.length;
        int a = 0;
        int b = 0;
        if (length > 2){
            return "只买两种水果的话，购买的水果数量超过两种";
        }else if (length == 0){
            return zero;
        }
        a = Integer.parseInt(cou[0]);
        if (length == 2){
            b = Integer.parseInt(cou[1]);
        }
        Integer sum = (8 * a) + (b * 13);
        return biaozhun + sum.toString();
    }

    /**
     * 输入题目2
     * @param number 水果行
     * @return 回复语句
     */
    public static String two(String number){
        String[] cou = number.split(regex);
        int length = cou.length;
        int a = 0;
        int b = 0;
        int c = 0;
        if (length > 3){
            return "买三种水果的话，购买的水果数量超过三种";
        }else if (length == 0){
            return zero;
        }
        a = Integer.parseInt(cou[0]);
        if (length > 1){
            b = Integer.parseInt(cou[1]);
        }
        if (length == 3){
            c = Integer.parseInt(cou[2]);
        }
        Integer sum = (8 * a) + (b * 13) + (20 * c);
        return biaozhun + sum.toString();
    }

    /**
     * 输入题目3
     * @param number 水果行
     * @return 回复语句
     */
    public static String three(String number){
        String[] cou = number.split(regex);
        int length = cou.length;
        int a = 0;
        int b = 0;
        int c = 0;
        if (length > 3){
            return "买三种水果的话，购买的水果数量超过三种";
        }else if (length == 0){
            return zero;
        }
        a = Integer.parseInt(cou[0]);
        if (length > 1){
            b = Integer.parseInt(cou[1]);
        }
        if (length == 3){
            c = Integer.parseInt(cou[2]);
        }
        return caomei + biaozhun + bigDecimal08(a, b ,c).toString();
    }

    /**
     * 输入题目4
     * @param number 水果行
     * @return 回复语句
     */
    public static String four(String number){
        String[] cou = number.split(regex);
        int length = cou.length;
        int a = 0;
        int b = 0;
        int c = 0;
        if (length > 3){
            return "买三种水果的话，购买的水果数量超过三种";
        }else if (length == 0){
            return zero;
        }
        a = Integer.parseInt(cou[0]);
        if (length > 1){
            b = Integer.parseInt(cou[1]);
        }
        if (length == 3){
            c = Integer.parseInt(cou[2]);
        }
        BigDecimal sumabc = bigDecimal08(a, b ,c);
        BigDecimal onehund = new BigDecimal(onehundred);
        BigDecimal sumall = sumabc;
        if (1 == sumabc.compareTo(onehund)){
            BigDecimal eee = sumabc.divide(onehund);
            int ddd = eee.intValue();
            int cut = ddd * ten;
            sumall = sumabc.subtract(BigDecimal.valueOf(cut));
        }
        return "购物满 100 减 10 块且" + caomei + biaozhun + sumall.toString();
    }

    /**
     * 计算0.8折扣
     * @param a a数量
     * @param b b数量
     * @param c c数量
     * @return
     */
    public static BigDecimal bigDecimal08(int a, int b, int c){
        Integer sum = (8 * a) + (20 * c);
        BigDecimal decimal = new BigDecimal(caomeisum);
        BigDecimal sumb = decimal.multiply(BigDecimal.valueOf(b * 13));
        BigDecimal sumac = new BigDecimal(sum);
        return sumac.add(sumb);
    }
}
